import App from './App'
import util from 'utils/util'
import configs from './config/app.js'

import zh from './locale/zh.js'
import en from './locale/en.js'

import Vue from 'vue'
import VueI18n from "vue-i18n";
Vue.use(VueI18n);

const i18n = new VueI18n({
	locale: uni.getStorageSync('locale') || 'en', // 语言标识
	// messages: {
	//   'zh': require('@/locale/zh.js'),
	//   'en': require('@/locale/en.js')
	// },
	messages: {
		'zh': zh,
		'en': en
	},
})

//解决i18n打包h5导航标题%**%
const mixin = {
	data() {
		return {
			_appTitle: ''
		}
	},
	onShow() {
		this.$nextTick(()=>{
			let title = this._appTitle || document.title
			if(title[0] === '%'){
				this._appTitle = document.title
				document.title = this.$t(title.replace(/\%/g,''))
			}
		})
	}
}

Vue.config.productionTip = false
Vue.prototype._i18n = i18n
Vue.prototype.$util = util;
Vue.prototype.$config = configs;
App.mpType = 'app'

// #ifdef MP
const app = new Vue({
	i18n,
	...App
})
app.$mount()
// #endif

// #ifdef H5
const app = new Vue({
	i18n,
	...App,
	mixins: [mixin]
})
app.$mount()
// #endif

